//
//  UIBarButtonItem+WJBarButtonItem.m
//  每日一笑
//
//  Created by WJ on 16/2/25.
//  Copyright © 2016年 WJ. All rights reserved.
//

#import "UIBarButtonItem+WJBarButtonItem.h"

@implementation UIBarButtonItem (WJBarButtonItem)

+ (instancetype)itemWithImage:(NSString *)image highImage:(NSString *)highImage target:(id)target action:(SEL)action {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [button setBackgroundImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    
    [button setBackgroundImage:[UIImage imageNamed:highImage] forState:UIControlStateHighlighted];
    
//    button.size = button.currentBackgroundImage.size;
    
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    return [[self alloc] initWithCustomView:button];
}

@end
